﻿using UnityEngine;

namespace Yoozoo.Modules.InnerCity
{
    public class IdleAction : ActionBase
    {
        private float stayTime;
        private float hasStayTime;

        protected override StateAction state
        {
            get => StateAction.Idle;
        }

        public override void Init(CityUnit owner)
        {
            base.Init(owner);
        }

        public override void Enter(object args = null)
        {
            Debug.Log("进入了待机状态");
            this.stayTime = args == null ? -1 : (float) args;
            this.hasStayTime = 0;
            this.owner.PlayIdleAni();
        }

        public override void Play()
        {
            if (this.stayTime == -1)
                return;

            this.hasStayTime += Time.deltaTime;
            if (this.hasStayTime >= this.stayTime)
                this.owner.CallNewRandomWalk();
        }

        public override void Exit()
        {
            Debug.Log("退出了待机状态");
        }
    }
}